package lab02.test11;

public class Rectangle implements Printx{
    @Override
    //行为：printMyWay()方法要能显示矩形的边长、面积和周长
    public void printMyWay() {
        System.out.println("该矩形的长a="+a+"宽b="+b);
        System.out.println("该矩形的面积s="+getArea());
        System.out.println("该矩形的周长l="+getLength());
    }
    double a,b;
    Rectangle(double a,double b){
        this.a=a;
        this.b=b;
    }
    //行为：求面积、求周长的方法
    public double getArea(){
        return a*b;
    }
    public double getLength(){
        return (a+b)*2.0;
    }
}
